home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / System / XFD / Developer / Sources / ASM / RLE.a < prev    next >
Encoding:
Text File  |  2001-09-16  |  2.4 KB  |  121 lines

  1. *******************************************************
  2. **     XFD external decruncher for RLE Cruncher      **
  3. **        written by Mr. Larmer / Wanted Team        **
  4. **       shortened and fixed by SDI in 2000           **
  5. *******************************************************
  6.  
  7.         INCLUDE    AINCLUDE:IncDirs.i
  8.         INCLUDE    "libraries/xfdmaster.i"
  9.  
  10.         * head function for tests
  11. *        INCLUDE    "xfdExeHead.a"
  12.  
  13. ; xfdForeman structure MUST be first thing in all external decrunchers
  14.  
  15. ForeMan        moveq    #-1,d0        ;security
  16.         rts
  17.         dc.l    XFDF_ID        ;id
  18.         dc.w    1        ;version
  19.         dc.w    0
  20.         dc.l    0,0        ;private
  21.         dc.l    S_RLE        ;first slave
  22.  
  23.         dc.b    "$VER: RLE 2.0 (22.04.2000)",0
  24. N_RLE        dc.b    "(RLE) Data Cruncher",0
  25.         EVEN
  26.  
  27. **************************************************
  28.  
  29. ; xfdSlave structure: this one doesn't support segment decrunching
  30.  
  31. S_RLE        dc.l    0        ;no more slaves
  32.         dc.w    2        ;version
  33.         dc.w    39        ;master version
  34.         dc.l    N_RLE        ;name
  35.         dc.w    XFDPFF_DATA|XFDPFF_USERTARGET|XFDPFF_RECOGLEN
  36.         dc.w    0
  37.         dc.l    RB_RLE
  38.         dc.l    DB_RLE
  39.         dc.l    SD_RLE
  40.         dc.l    VD_RLE
  41.         dc.w    0,0
  42.         dc.l    65
  43.  
  44. ;-------------------------------------------------
  45.  
  46. RB_RLE        MOVEQ    #0,D0
  47.         CMP.L    #"RLE"<<8,(A0)
  48.         BNE.B    .Exit
  49.         TST.B    4(A0)
  50.         BNE.B    .Exit
  51.         MOVE.L    4(A0),D0
  52.         MOVE.L    D0,xfdrr_FinalTargetLen(A1)
  53.         MOVE.L    D0,xfdrr_MinTargetLen(A1)
  54.         MOVE.L    8(A0),D0
  55.         ADDI.L    #64,D0
  56.         MOVE.L    D0,xfdrr_MinSourceLen(A1)
  57.         MOVEQ    #1,D0
  58. .Exit        RTS
  59.  
  60. SD_RLE        MOVEQ    #0,D0
  61.         CMP.L    #"RLE"<<8,(A0)
  62.         BNE.B    .end
  63.         MOVEQ    #1,D0
  64. .end        RTS
  65.  
  66. VD_RLE        MOVEQ    #64,D1
  67.         ADD.L    8(A0),D1    ;crlen
  68.         CMP.L    D0,D1        ;crlen > buflen ??
  69.         BGT.B    .Exit
  70.         MOVE.L    4(A0),D0
  71.         SUB.L    8(A0),D0    ;cr > uncr ??
  72.         BMI.B    .Exit
  73.         MOVE.L    D1,D0
  74.         RTS
  75. .Exit        MOVEQ    #0,D0
  76.         RTS
  77.  
  78. DB_RLE        MOVEM.L    D2-D7/A2-A6,-(A7)
  79.         MOVE.L    xfdbi_UserTargetBuf(A0),A1
  80.         MOVE.L    xfdbi_SourceBuffer(A0),A0
  81.  
  82.         BSR.B    D_RLE
  83.         
  84.         MOVEQ    #1,D0
  85. .Exit        MOVEM.L    (A7)+,D2-D7/A2-A6
  86.         RTS
  87.  
  88. **************************************************
  89.  
  90. D_RLE        MOVEA.L    A1,A4
  91.         ADDA.L    4(A0),A1    * A1 = destination end
  92.         MOVEA.L    A0,A2
  93.         ADDA.L    8(A0),A2    * A2 = source end - 64
  94.         MOVE.L    A2,D0
  95.         ADDQ.L    #1,D0
  96.         ANDI.B    #$FE,D0
  97.         MOVEA.L    D0,A3
  98.         MOVEQ    #15,D0
  99. .COPY        MOVE.L    (A3)+,(A4)+
  100.         DBRA    D0,.COPY
  101.  
  102. .LBC000046:    MOVE.B    -(A2),D0
  103.         BPL.S    .LBC00005A
  104.         NEG.B    D0
  105.         BMI.S    .end
  106.         EXT.W    D0
  107.         MOVE.B    -(A2),D1
  108. .LBC000052:    CMP.L    A4,A1
  109.         BEQ.B    .end
  110.         MOVE.B    D1,-(A1)
  111.         DBRA    D0,.LBC000052
  112.         BRA.S    .LBC000046
  113. .LBC00005A:    EXT.W    D0
  114. .LBC00005C:    CMP.L    A4,A1
  115.         BEQ.B    .end
  116.         MOVE.B    -(A2),-(A1)
  117.         DBRA    D0,.LBC00005C
  118.         BRA.S    .LBC000046
  119. .end        RTS
  120.         END
  121.